home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / tar.gnu / sprite / RCS / sprite.c,v < prev    next >
Encoding:
Text File  |  1992-03-29  |  4.2 KB  |  220 lines

  1. head     1.4;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.4
  10. date     92.03.28.17.32.44;  author kupfer;  state Exp;
  11. branches ;
  12. next     1.3;
  13.  
  14. 1.3
  15. date     92.03.05.21.38.38;  author rab;  state Exp;
  16. branches ;
  17. next     1.2;
  18.  
  19. 1.2
  20. date     90.06.28.15.35.42;  author rab;  state Exp;
  21. branches ;
  22. next     1.1;
  23.  
  24. 1.1
  25. date     90.03.21.23.18.06;  author rab;  state Exp;
  26. branches ;
  27. next     ;
  28.  
  29.  
  30. desc
  31. @@
  32.  
  33.  
  34. 1.4
  35. log
  36. @Fix to allow both a long file name and a long link name.  Lint.
  37. @
  38. text
  39. @/*
  40.  * sprite.c --
  41.  *    Sprite dependent routines to make named pipes, pseudo devices, etc.
  42.  */
  43.  
  44. #include <stdio.h>
  45. #include <errno.h>
  46. #include <sys/types.h>
  47. #include <sys/stat.h>
  48.  
  49. #include "sprite.h"
  50. #include "status.h"
  51. #include "fs.h"
  52. #include "tar.h"
  53.  
  54. /*
  55.  * SpriteMakeNamedPipe --
  56.  *    Create a named pipe under Sprite.  This uses the name from the
  57.  *    tar record header, and the read-write-execute bits from the
  58.  *    mode of the file.  This assumes that the tar tape was made
  59.  *    under Sprite, or that the UNIX read-write-execute bits are
  60.  *    the same as Sprite's, which is indeed the case.
  61.  */
  62. int
  63. SpriteMakeNamedPipe(name, hstat)
  64.     char *name;
  65.     struct stat *hstat;
  66. {
  67.     ReturnStatus status;
  68.     int streamID;
  69.     int flags;
  70.  
  71.     if (f_keep) {
  72.     flags = FS_CREATE|FS_NAMED_PIPE_OPEN|FS_EXCLUSIVE;
  73.     } else {
  74.     flags = FS_CREATE|FS_NAMED_PIPE_OPEN;
  75.     }
  76.  
  77.     status = Fs_Open(name, flags, hstat->st_mode & 0777, &streamID);
  78.     if (status == SUCCESS) {
  79.     (void)Fs_Close(streamID);
  80.     return(0);
  81.     } else {
  82.     /*
  83.      * Let our caller deal with errors.  It may need to make
  84.      * parent directories, etc.
  85.      */
  86.     errno = Compat_MapCode(status);
  87.     return(-1);
  88.      }
  89. }
  90.  
  91. /*
  92.  * SpriteMakePseudoDev --
  93.  *    Create a pseudo device under Sprite.  This uses the name from the
  94.  *    tar record header, and the read-write-execute bits from the
  95.  *    mode of the file.  This assumes that the tar tape was made
  96.  *    under Sprite, or that the UNIX read-write-execute bits are
  97.  *    the same as Sprite's, which is indeed the case.
  98.  */
  99. int
  100. SpriteMakePseudoDev(name, hstat)
  101.     char *name;
  102.     struct stat *hstat;
  103. {
  104.     ReturnStatus status;
  105.     int streamID;
  106.     int flags;
  107.  
  108.     if (f_keep) {
  109.     flags = FS_CREATE|FS_PDEV_MASTER|FS_EXCLUSIVE;
  110.     } else {
  111.     flags = FS_CREATE|FS_PDEV_MASTER;
  112.     }
  113.  
  114.     status = Fs_Open(name, flags, hstat->st_mode & 0777, &streamID);
  115.     if (status == SUCCESS) {
  116.     (void)Fs_Close(streamID);
  117.     return(0);
  118.     } else {
  119.     /*
  120.      * Let our caller deal with errors.  It may need to make
  121.      * parent directories, etc.
  122.      */
  123.     errno = Compat_MapCode(status);
  124.     return(-1);
  125.      }
  126. }
  127.  
  128. /*
  129.  * SpriteMakeRemoteLink --
  130.  *    Create a remote link under Sprite.  This uses the name from the
  131.  *    tar record header, and the read-write-execute bits from the
  132.  *    mode of the file.  This assumes that the tar tape was made
  133.  *    under Sprite, or that the UNIX read-write-execute bits are
  134.  *    the same as Sprite's, which is indeed the case.
  135.  */
  136. int
  137. SpriteMakeRemoteLink(linkname, name)
  138.     char *linkname;    /* Name referred to by link */
  139.     char *name;        /* Name of file created */
  140. {
  141.     ReturnStatus status;
  142.  
  143.     status = Fs_SymLink(linkname, name, TRUE);
  144.     if (status == SUCCESS) {
  145.     return(0);
  146.     } else {
  147.     /*
  148.      * Let our caller deal with errors.  It may need to make
  149.      * parent directories, etc.
  150.      */
  151.     errno = Compat_MapCode(status);
  152.     return(-1);
  153.      }
  154. }
  155.  
  156. @
  157.  
  158.  
  159. 1.3
  160. log
  161. @Lint (Mike checking in for Bob).
  162. @
  163. text
  164. @d7 1
  165. a13 1
  166. #include "compat.h"
  167. d25 2
  168. a26 2
  169. SpriteMakeNamedPipe(header, hstat)
  170.     union record *header;
  171. d39 1
  172. a39 2
  173.     status = Fs_Open(header->header.name, flags, hstat->st_mode & 0777,
  174.                 &streamID);
  175. d62 2
  176. a63 2
  177. SpriteMakePseudoDev(header, hstat)
  178.     union record *header;
  179. d76 1
  180. a76 2
  181.     status = Fs_Open(header->header.name, flags, hstat->st_mode & 0777,
  182.                 &streamID);
  183. a103 1
  184.     int streamID;
  185. @
  186.  
  187.  
  188. 1.2
  189. log
  190. @Added support for long filenames and long symbolic linkes.
  191. @
  192. text
  193. @d25 2
  194. a26 2
  195. SpriteMakeNamedPipe(head, hstat)
  196.     union record *head;
  197. d39 1
  198. a39 1
  199.     status = Fs_Open(head->header.name, flags, hstat->st_mode & 0777,
  200. d63 2
  201. a64 2
  202. SpriteMakePseudoDev(head, hstat)
  203.     union record *head;
  204. d77 1
  205. a77 1
  206.     status = Fs_Open(head->header.name, flags, hstat->st_mode & 0777,
  207. @
  208.  
  209.  
  210. 1.1
  211. log
  212. @Initial revision
  213. @
  214. text
  215. @a15 3
  216. TAR_EXTERN char f_keep;
  217. TAR_EXTERN int errno;
  218.  
  219. @
  220.